/**
 * Created by Administrator on 2017/2/27.
 */
var RealName = require('../../src/complex/realName');
var AccountInfo = require('../../src/complex/accountInfo');

var Root = React.createClass({
    getInitialState: function () {
        return{
            realName:PageDM.realNameInfo.value,
            realNameVal:PageDM.realName.value,
            phoneNumVal: PageDM.phoneNum.value,
            ownPwdVal: PageDM.ownPwd.value
        }
    },
    componentDidMount: function(){
        var _this = this;
        //个人实名信息
        UEventHub.on(PageDM.realNameInfo.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.refs.realName.setState({
                data: v
            })
        });
        //个人实名信息
        UEventHub.on(PageDM.realName.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.refs.accountInfo.setState({
                realName: v
            });
        });
        UEventHub.on(PageDM.phoneNum.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.refs.accountInfo.setState({
                phoneNum: v
            });
        });
        UEventHub.on(PageDM.ownPwd.dmbind + UI_EVENT_CONST.SET_UDM_VALUE_EVENT, function(v){
            _this.refs.accountInfo.setState({
                ownPwd: v
            });
        });
        UEventHub.emit("pageLoad","hello world!");
    },
    render: function() {
        var _this = this;
        var _accountinfo_data = {
            realName: _this.state.realNameVal,
            phoneNum: _this.state.phoneNumVal,
            ownPwd: _this.state.ownPwdVal
        };
        return (
            <div>
                <div className="mod-account container">
                    <div className="sub-nav">
                        <RealName ref="realName" data={this.state.realName}/>
                    </div>
                    <div className="account padding">
                        <AccountInfo ref="accountInfo" data={_accountinfo_data}/>
                    </div>
                    <div className="clear"></div>
                </div>
            </div>
        )
    }
});
ReactDOM.render(<Root/>, document.getElementById('giraffe'));